package ar.com.personalTravellers.daos.impl;

import ar.com.personalTravellers.beans.Client;
import ar.com.personalTravellers.beans.Country;
import ar.com.personalTravellers.daos.ClientDAO;
import com.angel.arquitectura.model.objectId.ObjectId;
import com.angel.dao.generic.impl.GenericSpringHibernateDAO;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author William
 */
public class ClientSpringHibernateDAO extends GenericSpringHibernateDAO<Client, ObjectId> implements ClientDAO {

    public ClientSpringHibernateDAO() {
        super(Client.class, ObjectId.class);
    }

    public Client findUniqueOrNullByNameSurnameAndEmail(String clientName, String clientSurname, String email) {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("name", clientName);
        parameters.put("surname", clientSurname);
        parameters.put("email", email);
        return super.findUniqueOrNull(parameters);
    }

    public Client findUniqueOrNullByNameAndSurname(String clientName, String clientSurname) {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("name", clientName);
        parameters.put("surname", clientSurname);
        return super.findUniqueOrNull(parameters);
    }


    public Collection<Client> findAllByName(String clientName) {
        return super.findAll("name", clientName);
    }

    public Collection<Client> findAllBySurName(String clientSurname) {
        return super.findAll("surname", clientSurname);
    }

    public Client findUniqueByNameAndSurname(String clientName, String clientSurname) {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("name", clientName);
        parameters.put("surname", clientSurname);
        return super.findUnique(parameters);
    }

    public Collection<Client> findAllByCountry(Country country) {
        return super.findAll("country", country);
    }

    public Client findUniqueByEmail(String email) {
        return super.findUnique("email", email);
    }

    public Client findUniqueByTelephone(String telephone) {
        return super.findUnique("telephone", telephone);
    }
}